using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace JQueryControlToolkit.Controls
{
	[ParseChildren(true, "Items"), PersistChildren(false)]
	public class Accordion : WebControl
	{
		private AccordionExtender extender = new AccordionExtender();
		public bool Disabled
		{
			get
			{
				return this.extender.Disabled;
			}
			set
			{
				this.extender.Disabled = value;
			}
		}
		public bool Collapsible
		{
			get
			{
				return this.extender.Collapsible;
			}
			set
			{
				this.extender.Collapsible = value;
			}
		}
		[PersistenceMode(PersistenceMode.InnerDefaultProperty)]
		public List<AccordionItem> Items
		{
			get;
			set;
		}
		public override string ID
		{
			get
			{
				return base.ID;
			}
			set
			{
				base.ID = value;
			}
		}
		protected override string TagName
		{
			get
			{
				return "div";
			}
		}
		protected override HtmlTextWriterTag TagKey
		{
			get
			{
				return HtmlTextWriterTag.Div;
			}
		}
		public Accordion()
		{
			this.Items = new List<AccordionItem>();
		}
		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);
		}
		protected override void RenderContents(HtmlTextWriter writer)
		{
			foreach (AccordionItem item in this.Items)
			{
				if (item.IsActive)
				{
					if (!string.IsNullOrEmpty(this.extender.ActiveItemSelector))
					{
						throw new NotSupportedException("Only one accordion item can be active at once.");
					}
					this.extender.ActiveItemSelector = "#" + item.ClientID;
				}
			}
			this.extender.TargetControlSelector = "#" + this.ClientID;
			foreach (AccordionItem item in this.Items)
			{
				item.RenderControl(writer);
			}
			this.extender.RenderControl(writer);
		}
	}
}
